package stream_hub

type StreamHubReq struct {
	Id               string `json:"id" comment:"协转任务id"`
	TenantId         string `json:"tenant_id" comment:"租户" validate:"required"`
	Name             string `json:"name" comment:"任务名称"`
	Description      string `json:"description" comment:"任务描述"`
	Type             string `json:"type" comment:"任务类型。live - 直播，vod - 点播" validate:"required"`
	Input            Input  `json:"input" comment:"输入参数"`
	Output           Output `json:"output" comment:"输出参数"`
	OutputAddress    string `json:"serviceOutputAddress" comment:"输出参数"`
	OutputStreamName string `json:"outputStreamName" comment:""`
	CallbackAddress  string `json:"callbackAddress" comment:"回调地址"`
}

type Input struct {
	Format  string   `json:"format" comment:"输入源格式" validate:"required"`
	Type    string   `json:"type" comment:"推拉流类型" validate:"required"`
	Sources []Source `json:"sources" comment:"源数组"`
	Active  int      `json:"active" comment:"激活源索引"`
	Policy  Policy   `json:"policy" comment:"源切换配置"`
}

type Source struct {
	Id         string `json:"id" comment:"节点id"`
	Url        string `json:"url" comment:"源地址" validate:"required"`
	UdpAddress string `json:"udpAddress" comment:""`
	StreamName string `json:"streamName" comment:""`
}
type TransCodeSource struct {
	Id            string   `json:"id" comment:"节点id"`
	Url           string   `json:"url" comment:"源地址" validate:"required"`
	UdpAddress    string   `json:"udpAddress" comment:""`
	Advanced      Advanced `json:"advanced"`
	SchedulerMode string   `json:"schedulerMode"`
	ServiceLoadId string   `json:"serviceLoadId"`
}

type Advanced struct {
	ServiceId       string `json:"serviceId"`
	ServiceName     string `json:"serviceName"`
	ServiceProvider string `json:"serviceProvider"`
	VideoPid        string `json:"videoPid"`
	AudioPid        string `json:"audioPid"`
	PcrPid          string `json:"pcrPid"`
	PmtPid          string `json:"pmtPid"`
}

type Policy struct {
	Mode string `json:"mode" comment:"切换方式。manual-手动，auto-自动"`
}

type Output struct {
	Targets []Target `json:"targets" comment:"输出目标"`
	Delay   Delay    `json:"delay" comment:"延迟播放信息"`
	Acl     Acl      `json:"acl" comment:"访问控制"`
}

type Delay struct {
	Enable   string `json:"enable" comment:"是否延播。yes、no"`
	Duration int    `json:"duration" comment:"延播时长。单位：秒，默认10秒"`
}

type Target struct {
	Id                    string                `json:"id" comment:"节点id"`
	Format                string                `json:"format" comment:"输出格式" validate:"required"`
	Url                   string                `json:"url" comment:"输出地址" validate:"required"`
	Type                  string                `json:"type" comment:"pull push"`
	RedefinePlayUrlEnable string                `json:"redefinePlayUrlEnable" comment:"是否自定义地址 1是"`
	RedefinePlayUrlParams RedefinePlayUrlParams `json:"redefinePlayUrlParams" comment:"自定义地址参数"`
}

type RedefinePlayUrlParams struct {
	Path string `json:"path"`
	Sub  string `json:"sub"`
}

type Acl struct {
}

type StreamHubRes struct {
	TaskId           string    `json:"id" comment:"任务id"`
	TenantId         string    `json:"tenant_id" comment:"租户"`
	Name             string    `json:"name" comment:"任务名称"`
	Description      string    `json:"description" comment:"任务描述"`
	Type             string    `json:"type" comment:"任务类型。live - 直播，vod - 点播" `
	Input            InputRes  `json:"input" comment:"输入参数"`
	Output           OutputRes `json:"output" comment:"输出参数"`
	OutputAddress    string    `json:"serviceOutputAddress" comment:"输出参数"`
	OutputStreamName string    `json:"outputStreamName" comment:"输出参数"`
}

type InputRes struct {
	Format  string      `json:"format" comment:"输入源格式" validate:"required"`
	Type    string      `json:"type" comment:"推拉流类型" validate:"required"`
	Sources []SourceRes `json:"sources" comment:"源数组"`
	Active  int         `json:"num" comment:"激活源索引"`
	Policy  Policy      `json:"policy" comment:"源切换配置"`
}

type SourceRes struct {
	Id            string      `json:"id" comment:"节点id"`
	Url           string      `json:"url" comment:"源地址"`
	TransferState string      `json:"transferState" comment:"输入状态"`
	UdpAddress    string      `json:"udpAddress" comment:"udp 地址"`
	Num           int         `json:"num" comment:"0 主 1 备 2辅 3垫"`
	MonitorId     string      `json:"monitorId" comment:"监控id 用于转码"`
	Description   interface{} `json:"description" comment:"描述"`
}

type OutputRes struct {
	Targets []TargetRes `json:"targets" comment:"输出目标"`
	Delay   Delay       `json:"delay" comment:"延迟播放信息"`
	Acl     Acl         `json:"acl" comment:"访问控制"`
}

type TargetRes struct {
	Id                    string                `json:"id" comment:"id"`
	Format                string                `json:"format" comment:"输出格式"`
	Url                   string                `json:"url" comment:"输出地址"`
	Type                  string                `json:"type" comment:"pull push"`
	TransferState         string                `json:"transferState" comment:"输出状态"`
	AdditionalPublishUrl  string                `json:"additionalPublishUrl" comment:"额外hls的拉流地址"`
	RedefinePlayUrlEnable string                `json:"redefinePlayUrlEnable" comment:"是否自定义地址 1是"`
	RedefinePlayUrlParams RedefinePlayUrlParams `json:"redefinePlayUrlParams" comment:"自定义地址参数"`
}

type T struct {
	Id                          string      `json:"id"`
	ParentId                    string      `json:"parentId"`
	Format                      string      `json:"format"`
	Type                        string      `json:"type"`
	TransferState               string      `json:"transferState"`
	TransferStateLastUpdateTime int         `json:"transferStateLastUpdateTime"`
	PackageId                   string      `json:"packageId"`
	AdditionalPublishUrl        string      `json:"additionalPublishUrl"`
	ServiceLoadId               interface{} `json:"serviceLoadId"`
	SchedulerMode               string      `json:"schedulerMode"`
	RedefinePlayUrlEnable       string      `json:"redefinePlayUrlEnable"`
	RedefinePlayUrlParams       string      `json:"redefinePlayUrlParams"`
	Url                         string      `json:"url"`
}

type CreateRTCRes struct {
	Name               string             `json:"name"`
	InputType          string             `json:"input_type"`
	SdiPort            string             `json:"sdi_port"`
	InputSy            string             `json:"input_sy"`
	TaskMode           string             `json:"task_mode"`
	DistributeProvider string             `json:"distribute_provider"`
	IfGpu              string             `json:"if_gpu"`
	TranscoderParams   []TranscoderParams `json:"transcoder_params"`
	PackageSetting     PackageSetting     `json:"package_setting"`
	GroupId            string             `json:"group_id"`
	UserId             string             `json:"userId"`
}

type TranscoderParams []struct {
	Name            string `json:"name"`
	CodecMode       string `json:"codec_mode"`
	VideoCodec      string `json:"video_codec"`
	VideoBitrate    string `json:"video_bitrate"`
	VideoScale      string `json:"video_scale"`
	VideoFrameRate  string `json:"video_frame_rate"`
	VideoGop        int    `json:"video_gop"`
	AudioCodec      string `json:"audio_codec"`
	AudioBitrate    string `json:"audio_bitrate"`
	AudioSampleRate string `json:"audio_sample_rate"`
	UserId          string `json:"userId"`
	Type            string `json:"type"`
	Provider        string `json:"provider"`
	Id              string `json:"id"`
}

type PackageSetting struct {
	OutputFormat string `json:"output_format"`
}

type TransCodeReq struct {
	Id              string             `json:"id" comment:"转码任务id"`
	TenantId        string             `json:"tenant_id" comment:"租户" validate:"required"`
	Name            string             `json:"name"`
	Input           TransferCodeInput  `json:"input"`
	Output          TransferCodeOutput `json:"output"`
	Type            string             `json:"type"`
	CallbackAddress string             `json:"callbackAddress"`
	NgvsaServiceUrl string             `json:"ngvsaServiceUrl"`
	VrcServiceUrl   string             `json:"vrcServiceUrl"`
}

type TransferCodeInput struct {
	Format  string            `json:"format" comment:"输入源格式" validate:"required"`
	Type    string            `json:"type" comment:"推拉流类型" validate:"required"`
	Sources []TransCodeSource `json:"sources" comment:"源数组"`
	Active  int               `json:"active" comment:"激活源索引"`
	Policy  Policy            `json:"policy" comment:"源切换配置"`
}

type TransferCodeOutput struct {
	Template Template `json:"template"`
}

type Template struct {
	TemplateId   string `json:"templateId"`
	Acodec       string `json:"acodec"`
	AudioBitrate int    `json:"audioBitrate"`
	Vcodec       string `json:"vcodec"`
	VideoBitrate int    `json:"videoBitrate"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	Fps          int    `json:"fps"`
	Gop          int    `json:"gop"`
	Profile      string `json:"profile"`
	SampleRate   string `json:"sample_rate"`
}

type TransCodeRes struct {
	Id              string               `json:"id" comment:"转码任务id"`
	TenantId        string               `json:"tenantId" comment:"租户" validate:"required"`
	Name            string               `json:"name"`
	Input           TransferCodeInputRes `json:"input"`
	Output          TransferCodeOutput   `json:"output"`
	Type            string               `json:"type"`
	CallbackAddress string               `json:"callbackAddress"`
	OutputAddress   string               `json:"serviceOutputAddress" comment:"输出参数"`
}

//type TransferCodeInputRes struct {
//	Format  string      `json:"format" comment:"输入源格式" validate:"required"`
//	Type    string      `json:"type" comment:"推拉流类型" validate:"required"`
//	Sources []SourceRes `json:"sources" comment:"源数组"`
//	Active  int         `json:"active" comment:"激活源索引"`
//	Policy  Policy      `json:"policy" comment:"源切换配置"`
//}

type TransferCodeInputRes struct {
	Id          string                    `json:"id"`
	Name        string                    `json:"name"`
	Description interface{}               `json:"description"`
	Type        string                    `json:"type"`
	Active      string                    `json:"active"`
	Policy      Policy                    `json:"policy" comment:"源切换配置"`
	Sources     []TransferCodeInputSource `json:"sources"`
}

type TransferCodeInputSource struct {
	Id                          string `json:"id"`
	ParentId                    string `json:"parentId"`
	PackageId                   string `json:"packageId"`
	TransferState               string `json:"transferState"`
	TransferStateLastUpdateTime int    `json:"transferStateLastUpdateTime"`
	UdpAddress                  string `json:"udpAddress"`
	Num                         int    `json:"num"`
	TranscoderLiveId            string `json:"transcoderLiveId"`
	TranscoderPackageId         string `json:"transcoderPackageId"`
	TranscoderClodLivePushUrl   string `json:"transcoderClodLivePushUrl"`
	MonitorId                   string `json:"monitorId"`
	Url                         string `json:"url"`
}

type SwitchSourceReq struct {
	Id              string      `json:"id" comment:"转码任务id"`
	TenantId        string      `json:"tenantId" comment:"租户" validate:"required"`
	Name            string      `json:"name"`
	SwitchInput     SwitchInput `json:"input"`
	Type            string      `json:"type"`
	CallbackAddress string      `json:"callbackAddress"`
	OutputAddress   string      `json:"serviceOutputAddress" comment:"输出参数"`
	AutoSwitch      int         `json:"autoSwitch" comment:"1 - 自动切换，0 - 不自动切换"`
}

type SwitchInput struct {
	Format  string   `json:"format"`
	Type    string   `json:"type"`
	Sources []Source `json:"sources"`
	Active  int      `json:"active"`
	Policy  Policy   `json:"policy" comment:"源切换配置"`
}

type SwitchSourceRes struct {
	TaskId        string         `json:"id" comment:"任务id"`
	TenantId      string         `json:"tenant_id" comment:"租户"`
	Name          string         `json:"name" comment:"任务名称"`
	Description   string         `json:"description" comment:"任务描述"`
	Type          string         `json:"type" comment:"任务类型。live - 直播，vod - 点播" `
	Input         SwitchInputRes `json:"input" comment:"输入参数"`
	OutputAddress string         `json:"serviceOutputAddress" comment:"输出参数"`
}

type SwitchInputRes struct {
	Format  string   `json:"format"`
	Type    string   `json:"type"`
	Sources []Source `json:"sources"`
}

type ChangeSourceReq struct {
	Id       string `json:"id" comment:"切换任务id"`
	TenantId string `json:"tenantId" comment:"租户" validate:"required"`
	Active   int    `json:"active"`
}

type StartOrStopSwitchSourceReq struct {
	Id       string `json:"id" comment:"切换任务id"`
	TenantId string `json:"tenantId" comment:"租户" validate:"required"`
}

type EditRefinePlayUrlReq struct {
	Id                    string                `json:"id" comment:"切换任务id"`
	TenantId              string                `json:"tenantId" comment:"租户" validate:"required"`
	RedefinePlayUrlEnable string                `json:"redefinePlayUrlEnable" comment:"是否自定义地址 1是"`
	RedefinePlayUrlParams RedefinePlayUrlParams `json:"redefinePlayUrlParams" comment:"自定义地址参数"`
}

type TemplateInfo struct {
	Id         string      `json:"id"`
	Name       string      `json:"name"`
	Type       string      `json:"type"`
	Provider   interface{} `json:"provider"`
	Attributes Attribute   `json:"attribute"`
	Template   string      `json:"template"`
	Key        interface{} `json:"key"`
	CreateTime int64       `json:"create_time"`
	Format     string      `json:"format"`
}

type Attribute struct {
	Outputs []TemplateOutput `json:"output"`
}

type TemplateOutput struct {
	Bitrate       int    `json:"bitrate"`
	VideoCodec    string `json:"video_codec"`
	VideoWidth    int    `json:"video_width"`
	VideoHeight   int    `json:"video_height"`
	AacBitrate    string `json:"aac_bitrate"`
	AacSamplerate string `json:"aac_samplerate"`
	Fps           int    `json:"fps"`
	Ratio         string `json:"ratio"`
	EncodingType  string `json:"encodingType"`
	Rc            string `json:"rc"`
	Qualitylevel  string `json:"qualitylevel"`
	Profile       string `json:"profile"`
}

type ConvertParamReq struct {
	TenantId       string   `json:"tenantId" comment:"租户" validate:"required"`
	InputProtocol  string   `json:"input_protocol" comment:"1: rtmp 2: hls 3: httpts 4: srt 5 udp 6 flv 7 sdi"`
	InputUrls      []string `json:"input_urls" comment:"输入源"`
	OutputProtocol string   `json:"output_protocol" comment:"1: rtmp 2: hls 3: httpts 4: srt 5 udp 6 flv 7 sdi"`
	OutputUrls     []string `json:"output_urls" comment:"输出源"`
	Area           int      `json:"area" comment:"1 公网 2 内网"`
	StreamType     int      `json:"stream_type" comment:"1 推流 2 拉流"`
	InputType      string   `json:"output_type" comment:""`
}

type SetBlackWhiteParam struct {
	TenantId string   `json:"tenantId" comment:"租户" validate:"required"`
	Acl      []string `json:"acl"`
	TaskId   string   `json:"task_id"`
}

type DisPatchLimitRes struct {
	Count int    `json:"count"`
	Rows  []Rows `json:"rows"`
}
type Rows struct {
	Id            string        `json:"id"`
	Configuration Configuration `json:"configuration"`
	Quota         Quota         `json:"quota"`
	TenantId      string        `json:"tenantId"`
}

type Configuration struct {
	Streamhub Streamhub `json:"streamhub"`
}

type Streamhub struct {
	MutiNodeSchedule MutiNodeSchedule `json:"mutiNodeSchedule"`
}
type MutiNodeSchedule struct {
	DefaultNode string `json:"defaultNode"`
}

type Quota struct {
	MediaScheduler MediaScheduler `json:"mediaScheduler"`
	GlobalLive     GlobalLive     `json:"globalLive"`
}

type MediaScheduler struct {
	ParanDispatchNum int64 `json:"paranDispatchNum"`
}

type GlobalLive struct {
	Turn2OthersNum int `json:"turn2othersNum"`
	ParanPullNum   int `json:"paranPullNum"`
	ParanRecordNum int `json:"paranRecordNum"`
	StorageSize    int `json:"storageSize"`
}
